//
//  AY_BookShelEditCell.m
//  AiYue
//
//  Created by boWen on 2023/11/15.
//

#import "AY_BookShelEditCell.h"

@interface AY_BookShelEditCell ()
/** 书 */
@property (strong,nonatomic) UIImageView *bookImage;

/** 书名 */
@property (strong,nonatomic) UILabel *bookName;

/** 书名 */
@property (strong,nonatomic) UILabel *desLabel;

@property (strong,nonatomic) UIImageView * seleImgView;

@end

@implementation AY_BookShelEditCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.bookImage = [AYTool createImageViewWithFrame:CGRectZero andImage:nil andBg:nil andRadius:YNUM(4) andAddSubView:self.contentView];
        [self.bookImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.mas_equalTo(YNUM(140));
            make.left.right.equalTo(self.contentView);
            make.top.equalTo(self.contentView).offset(YNUM(15));
        }];
        
        self.bookName = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:COLOR(@"#000002") andBgColor:nil andFont:[UIFont boldSystemFontOfSize:YNUM(14)] andLines:2 andRadius:0 andAddSubView:self.contentView];
        [self.bookName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.bookImage.mas_bottom).offset(YNUM(5));
            make.left.equalTo(self.bookImage);
            make.right.equalTo(self.contentView).offset(-YNUM(15));
        }];
        
        self.desLabel = [AYTool createLabelWithFrame:CGRectZero andText:nil andTextColor:COLOR(@"#97A4B0") andBgColor:nil andFont:YFont(12) andLines:1 andRadius:0 andAddSubView:self.contentView];
        [self.desLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.equalTo(self.bookName);
            make.bottom.equalTo(self.contentView);
        }];
        
        self.seleImgView = [AYTool createImageViewWithFrame:CGRectZero andImage:YImage(@"baseNoSelect.png") andBg:nil andRadius:0.0 andAddSubView:self.bookImage];
        [self.seleImgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.height.width.mas_equalTo(YNUM(20));
            make.right.equalTo(self.bookImage).offset(YNUM(-3));
            make.bottom.equalTo(self.bookImage).offset(YNUM(-3));
        }];
        
    }
    return self;
}

- (void)sendBookSelfModel:(BookSelfModel *)model {
    self.bookName.hidden = NO;
    self.desLabel.hidden = NO;
    self.bookName.text = model.articleTitle;
    self.desLabel.text = [NSString stringWithFormat:@"%@章/%@章",model.chapterNo,model.chapterCount];
    [self.bookImage sd_setImageWithURL:[NSURL URLWithString:model.articleCoverImg] placeholderImage:YImage(@"placeholderImage")];
}


- (void)setSelected:(BOOL)selected {
    [super setSelected:selected];
    if(selected) {
        self.seleImgView.image = YImage(@"baseSelect.png");
    }else {
        self.seleImgView.image = YImage(@"baseNoSelect.png");
    }
}
@end
